/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package utn.frsf.cidisi.upcolbpip.b2bcollaborations.impl;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

import utn.frsf.cidisi.upcolbpip.b2bcollaborations.AgreementAtribute;
import utn.frsf.cidisi.upcolbpip.b2bcollaborations.B2bcollaborationsPackage;
import utn.frsf.cidisi.upcolbpip.b2bcollaborations.BusinessGoal;
import utn.frsf.cidisi.upcolbpip.b2bcollaborations.CollaborativeAgreement;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Collaborative Agreement</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link utn.frsf.cidisi.upcolbpip.b2bcollaborations.impl.CollaborativeAgreementImpl#getName <em>Name</em>}</li>
 *   <li>{@link utn.frsf.cidisi.upcolbpip.b2bcollaborations.impl.CollaborativeAgreementImpl#getCollaborativeModel <em>Collaborative Model</em>}</li>
 *   <li>{@link utn.frsf.cidisi.upcolbpip.b2bcollaborations.impl.CollaborativeAgreementImpl#getAtributes <em>Atributes</em>}</li>
 *   <li>{@link utn.frsf.cidisi.upcolbpip.b2bcollaborations.impl.CollaborativeAgreementImpl#getFormedBy <em>Formed By</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class CollaborativeAgreementImpl extends EObjectImpl implements CollaborativeAgreement {
	/**
	 * The default value of the '{@link #getName() <em>Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getName()
	 * @generated
	 * @ordered
	 */
	protected static final String NAME_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getName() <em>Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getName()
	 * @generated
	 * @ordered
	 */
	protected String name = NAME_EDEFAULT;

	/**
	 * The default value of the '{@link #getCollaborativeModel() <em>Collaborative Model</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getCollaborativeModel()
	 * @generated
	 * @ordered
	 */
	protected static final String COLLABORATIVE_MODEL_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getCollaborativeModel() <em>Collaborative Model</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getCollaborativeModel()
	 * @generated
	 * @ordered
	 */
	protected String collaborativeModel = COLLABORATIVE_MODEL_EDEFAULT;

	/**
	 * The cached value of the '{@link #getAtributes() <em>Atributes</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getAtributes()
	 * @generated
	 * @ordered
	 */
	protected EList<AgreementAtribute> atributes;

	/**
	 * The cached value of the '{@link #getFormedBy() <em>Formed By</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getFormedBy()
	 * @generated
	 * @ordered
	 */
	protected EList<BusinessGoal> formedBy;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected CollaborativeAgreementImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return B2bcollaborationsPackage.Literals.COLLABORATIVE_AGREEMENT;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getName() {
		return name;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setName(String newName) {
		String oldName = name;
		name = newName;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, B2bcollaborationsPackage.COLLABORATIVE_AGREEMENT__NAME, oldName, name));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getCollaborativeModel() {
		return collaborativeModel;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setCollaborativeModel(String newCollaborativeModel) {
		String oldCollaborativeModel = collaborativeModel;
		collaborativeModel = newCollaborativeModel;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, B2bcollaborationsPackage.COLLABORATIVE_AGREEMENT__COLLABORATIVE_MODEL, oldCollaborativeModel, collaborativeModel));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<AgreementAtribute> getAtributes() {
		if (atributes == null) {
			atributes = new EObjectContainmentEList<AgreementAtribute>(AgreementAtribute.class, this, B2bcollaborationsPackage.COLLABORATIVE_AGREEMENT__ATRIBUTES);
		}
		return atributes;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<BusinessGoal> getFormedBy() {
		if (formedBy == null) {
			formedBy = new EObjectContainmentEList<BusinessGoal>(BusinessGoal.class, this, B2bcollaborationsPackage.COLLABORATIVE_AGREEMENT__FORMED_BY);
		}
		return formedBy;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case B2bcollaborationsPackage.COLLABORATIVE_AGREEMENT__ATRIBUTES:
				return ((InternalEList<?>)getAtributes()).basicRemove(otherEnd, msgs);
			case B2bcollaborationsPackage.COLLABORATIVE_AGREEMENT__FORMED_BY:
				return ((InternalEList<?>)getFormedBy()).basicRemove(otherEnd, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case B2bcollaborationsPackage.COLLABORATIVE_AGREEMENT__NAME:
				return getName();
			case B2bcollaborationsPackage.COLLABORATIVE_AGREEMENT__COLLABORATIVE_MODEL:
				return getCollaborativeModel();
			case B2bcollaborationsPackage.COLLABORATIVE_AGREEMENT__ATRIBUTES:
				return getAtributes();
			case B2bcollaborationsPackage.COLLABORATIVE_AGREEMENT__FORMED_BY:
				return getFormedBy();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case B2bcollaborationsPackage.COLLABORATIVE_AGREEMENT__NAME:
				setName((String)newValue);
				return;
			case B2bcollaborationsPackage.COLLABORATIVE_AGREEMENT__COLLABORATIVE_MODEL:
				setCollaborativeModel((String)newValue);
				return;
			case B2bcollaborationsPackage.COLLABORATIVE_AGREEMENT__ATRIBUTES:
				getAtributes().clear();
				getAtributes().addAll((Collection<? extends AgreementAtribute>)newValue);
				return;
			case B2bcollaborationsPackage.COLLABORATIVE_AGREEMENT__FORMED_BY:
				getFormedBy().clear();
				getFormedBy().addAll((Collection<? extends BusinessGoal>)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case B2bcollaborationsPackage.COLLABORATIVE_AGREEMENT__NAME:
				setName(NAME_EDEFAULT);
				return;
			case B2bcollaborationsPackage.COLLABORATIVE_AGREEMENT__COLLABORATIVE_MODEL:
				setCollaborativeModel(COLLABORATIVE_MODEL_EDEFAULT);
				return;
			case B2bcollaborationsPackage.COLLABORATIVE_AGREEMENT__ATRIBUTES:
				getAtributes().clear();
				return;
			case B2bcollaborationsPackage.COLLABORATIVE_AGREEMENT__FORMED_BY:
				getFormedBy().clear();
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case B2bcollaborationsPackage.COLLABORATIVE_AGREEMENT__NAME:
				return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
			case B2bcollaborationsPackage.COLLABORATIVE_AGREEMENT__COLLABORATIVE_MODEL:
				return COLLABORATIVE_MODEL_EDEFAULT == null ? collaborativeModel != null : !COLLABORATIVE_MODEL_EDEFAULT.equals(collaborativeModel);
			case B2bcollaborationsPackage.COLLABORATIVE_AGREEMENT__ATRIBUTES:
				return atributes != null && !atributes.isEmpty();
			case B2bcollaborationsPackage.COLLABORATIVE_AGREEMENT__FORMED_BY:
				return formedBy != null && !formedBy.isEmpty();
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (name: ");
		result.append(name);
		result.append(", collaborativeModel: ");
		result.append(collaborativeModel);
		result.append(')');
		return result.toString();
	}

} //CollaborativeAgreementImpl
